#@laybase() 
#define main()

#@orderProgress()
<div style="margin-top: 15px;overflow: hidden;">
	<div class="col-md-3">
	#setLocal(tabs=["-","运营商","产品","日期","姓名","进度"])
	#setLocal(attrs=["owner","Operator","product","date","name","step"])
	#@dataTable(tabs,attrs,orderList,"/admin/photoReview")
	</div>
	#@datashowbox()
	<div class="col-md-6">
		<div class="nano" style="height: 680px;overflow: hidden;position: relative;display: none;" id="databox">
			<div class="windowdata col-md-12 nano-content" id="dhdata">
				<div class="dh col-md-12">
					<ul id="dhlist"></ul>
					<button class='btn btn-primary'>提交</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="/assets/js/perfect-scrollbar.js"></script>
<script src="/assets/js/jquery.mousewheel.js"></script>
<script>
	$(function(){
		var dhdata = $("#dhdata"),//窗口
			datashowbox = $("#datashowbox"),//数据统计
			databox = $("#databox"),//数据展示层
			dhlist = $("#dhlist");
		
		function getJson(type,orderId){
			var params = {
				params: {
					type:type,
					orderId:orderId
				}
			}
			return axios.get("/admin/getJson",params)
		}
		
		databox.perfectScrollbar({
			suppressScrollX:true
		});
		
		/*datashowbox.find("select").change(function(){
			var orderId = $(this).val();
			$.getJSON("/admin/getJson",{type:8,orderId:orderId},function(data){
				datashowbox.hide();
				databox.show();
				getBaseTab(data);
			})
		})*/
		
		$("#rtable").on("click","tbody tr",function(){
			if($(this).hasClass("sel"))return;
			var orderId = $(this).data("orderid");
			$(this).addClass("sel").siblings("tr").removeClass("sel");
			axios.all([getJson(8,orderId),getJson(7,orderId)])
			.then(axios.spread(function(json1,json2){
				console.log(json1.data);
				datashowbox.hide();
				databox.show();
				getBaseTab(json1.data);
				
				_com.addMsg(databox,json2.data)
				
				axios.get("/admin/getAllStates")
				.then(function(progress){
					_com.renderOrderProgress(progress.data)
				})
			}))
			
			
		})
		
		function getBaseTab(data){
			var html = "",
				len = data.length;
			dhlist.html(html);
			for(var i = 0;i < len;i++){
				var tit = data[i].expl +"（"+ data[i].count +"）",
					express = "",
					notebox = "",
					noteText = "",
					noteStyle = "",
					selected = "",
					state = data[i].state;
				if(state == "3"){
					noteText = data[i].err;
					noteStyle = "style='display: block;'";
					selected = "selected='selected'";
				}
				notebox = "<select class='form-control' style='width: 12%;float: left;'>"+
						  "    <option value='5'>有</option>"+
						  "    <option value='3' "+ selected +">无</option>"+
						  "</select>"+
						  "<div class='notebox col-md-6' "+ noteStyle +">"+
						  "    <span>备注：</span>"+
						  "    <input type='text' class='form-control' name='"+ data[i].paramterName +"' value='"+ noteText +"' />"+
						  "</div>";
				if(i == len - 1 && data[i].value){
					tit = data[i].expl +"："+ data[i].value;
					express = "class='express'";
					notebox = "";
				}
				html += "<li "+ express +">"+
						"	<p class='col-md-4'>"+ tit +"</p>"+
							notebox+
						"</li>";
			}
			dhlist.append(html);
			databox.perfectScrollbar("update");
		}
		
		
		
		//显示备注
		dhlist.on("change","select",function(){
			var that = $(this),
				notebox = that.siblings(".notebox");
			if(that.val() == "5"){
				notebox.removeClass("submit").hide();
			}else if(that.val() == "3"){
				notebox.addClass("submit").show();
			}
		})
		
		//提交
		$("#dhdata .dh button").click(function(){//1车辆照片 2原件照片 3合同照片 4复审
			var data = [];//paramterName=字段名,state=状态（3:反馈;5:通过）,err=反馈内容
			dhlist.children("li").each(function(){
				var that = $(this),
					inputDom = that.children(".notebox").children("input"),
					state = that.children("select").val(),
					json = {};
				if(that.hasClass("express"))return false;
				json.paramterName = inputDom.attr("name");
				json.state = state;
				if(state == "3"){
					json.err = inputDom.val();
				}
				data.push(json);
			})	
			var newData = JSON.stringify(data);
			$.getJSON("/admin/afterLoanMsg",{data:newData},function(data){
				console.log(data)
				alert(data.msg)
			})
		})
	})
</script>
#end